package com.anti.modular.sys.user.dao.impl;

import com.anti.jdbc.DBUtils;
import com.anti.modular.sys.user.dao.SysUserDao;
import com.anti.modular.sys.user.entity.SysUser;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description TODO
 * @Author anTi
 * @Date 2021-3-12
 */
@Service
public class SysUserDaoImpl implements SysUserDao {
    @Resource
    DBUtils dbUtils;

    @Override
    public void save(SysUser sysUser) {
        Object o = dbUtils.insertKey(sysUser);
        long key = Long.parseLong(o.toString());
        sysUser.setId(key);
    }

    @Override
    public void update(SysUser sysUser) {
        dbUtils.update(sysUser);
    }

    @Override
    public boolean updateStatus(Integer status,Long id) {
        String sql="update sys_user set status=? where id =? and status <> 2";
        int execSql = dbUtils.execSql(sql,status, id);
        return execSql == 0 ? false : true;
    }
}
